package com.zzzyh.blogbyspring.pojo;

import com.zzzyh.blogbyspring.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> {
    private Integer code; // 200 成功 ; -1 失败
    private String message;
    private T data;

    public static <T> Response<T> success(String message,T data) {
        return new Response<>(Constants.SUCCESS_CODE, message, data);
    }

    public static <T> Response<T> fail( String message) {
        return new Response<>(Constants.FAIL_CODE, message, null);
    }
}
